import {combineReducers, configureStore} from "@reduxjs/toolkit";
import {persistReducer, persistStore} from "redux-persist";
import storageSession from "redux-persist/lib/storage/session";
import userStore from "@/store/modules/user.jsx";
import MenuStore from "@/store/modules/menu.jsx";
import SettingStore from "@/store/modules/setting.jsx";

const persistConfig = {
    key: "storage",
    storage: storageSession,
};
const allReducer = combineReducers({
    userStore: userStore,
    menuStore: MenuStore,
    settingStore: SettingStore,
}); //合并所有的模块
const persistedReducer = persistReducer(persistConfig, allReducer);
export const store = configureStore({
    reducer: persistedReducer,
    middleware: (getDefaultMiddleware) =>
        getDefaultMiddleware({
            serializableCheck: false,
        }),
});
export const persistor = persistStore(store);
